<template>
	<view class="page_box">
		<view class="head_box ">
			<yy-custom bgColor="bg-gradual-blue" v-if="0">
				<block slot="backText">返回</block>
				<block slot="content">导航栏</block>
			</yy-custom>
		</view>

		<view class="content_box padding-lr-xl">
			
			<view class="">
				<text class="text-black f46 text-bold  logIn">登录</text>
				<text class="text-gray f35   logIn  ml50" @click="registered">注册</text>
			</view>
			<view class="flex align-center  mt108 padding-tb  solid-bottom">
				<image src=../../static/shouji.png mode="aspectFill" class="w34 h34 "></image>
				<view class="w3 h26 bg-grey margin-lr"></view>
				<input type="text" value="" placeholder="请输入登录账号" v-model="account" placeholder-class="ddd" />
			</view>

			<view class="flex align-center  margin-top  padding-tb  solid-bottom">
				<view class="flex">
					<image src="../../static/mima.png" mode="aspectFill" class="w34 h34 "></image>
					<view class="w3 h26 bg-grey margin-lr"></view>
				</view>
				<view class="flex justify-between ww100">
					<input type="text" value="" placeholder="请输入登录密码" v-model="password"  password placeholder-class="ddd"  v-if='show' />
					<input type="text" value="" placeholder="请输入登录密码" v-model="password" placeholder-class="ddd" v-else/>
					
					<image src="../../static/yan2.png" mode="aspectFill" class="w34 h34" v-if="show" @click="show = !show"></image>
					<image src="../../static/yan1.png" mode="aspectFill" class="w34 h34" v-else @click="show = !show"></image>
				</view>
			</view>
			<button class="cu-btn btn mt100" @click="logIn">立即登录</button>
		</view>
		<view class="foot_box"></view>
		<!-- 登录提示 -->
		<yy-login v-if="false"></yy-login>
		<!-- 加载提示 -->
		<yy-loading text="加载中.." mask="true" click="true" ref="loading"></yy-loading>
		<!-- 信息提示-->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			show:true,
			account:'',
			password:'',
		};
	},
	onShow() {},
	onLoad(e) {},
	methods: {
		logInImmediately() {
			uni.switchTab({
				url: '/pages/hmPage/hmPage'
			});
		},
		async logIn(){
			if ([this.password , this.mobile].includes('')) {
					return this.$refs.uToast.show({ title: '请填写完整',type: 'error' });
			}
			if (!this.$u.test.mobile(this.account)) {
					return  this.$refs.uToast.show({ title: '手机号码输入不完整',type: 'error' });
			}	
			let obj = {
				account :this.account,
				password :this.password,
			};
			const res = await this.$u.post("/api/user/login",obj,{});
			if (res.code) {
				uni.setStorageSync('info', res.data.userinfo)
				
				this.$refs.uToast.show({ title: '登录成功',type: 'success' });
				setTimeout(() => {
					uni.switchTab({
						url: '../hmPage/hmPage',
					});
				}, 500);
			}else {
				this.password = ''
				this.$refs.uToast.show({ title: res.msg,type: 'error' });
			}
		},
		 registered(){
			uni.navigateTo({
				url: 'registered',
			});
			
			
		},
		

		
	}
};
</script>

<style lang="scss" scoped>
.page_box {
	.head_box {
	}
	.content_box {
		padding: 0 92rpx;
		margin-top: 200rpx;
		.ddd {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #999999;
		}
		.btn {
			width: 100%;
			height: 80rpx;
			background: #f07203;
			border-radius: 40rpx;

			font-size: 28rpx;

			font-weight: 500;
			color: #ffffff;
		}
	}
}
</style>
